package vip.xiaozhao.paotui.intf.mapper;

import org.apache.ibatis.annotations.*;
import vip.xiaozhao.paotui.intf.entity.PaotuiCollege;


@Mapper
public interface PaoTuiCollegeMapper {
    @Insert("INSERT INTO xzVIP_paotui_college  " +
            "    (id, CollegeName, `Status`, AddTime, UpdateTime) " +
            "    VALUES  " +
            "    (#{id}, #{collegeName}, #{status},now(), now()) ")
    @Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
    int insert(PaotuiCollege college);


    @Update("UPDATE xzVIP_paotui_college " +
            "SET CollegeName = #{collegeName}, " +
            "Status = #{status}, " +
            "UpdateTime = NOW() " +
            "WHERE id = #{id}")
    int update(PaotuiCollege college);

    @Select(" select * from xzVIP_paotui_college where id = #{id} ")
    PaotuiCollege loadById(int id) ;

    @Select("select * from xzVIP_paotui_college where id = " +
            "( select CollegeId from xzVIP_paotui_user_college where UserId = #{userId} and `Status` != 0 limit 1)")
    PaotuiCollege loadCollegeByUserId(int userId);



}
